package cn.hn.yh.service.sjxh;

import cn.hn.yh.dao.sjxh.da.DaSjxhDao;
import cn.hn.yh.serviceInterface.sjxh.da.DaSjxhServiceInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class DaSjxhService implements DaSjxhServiceInf {

    @Autowired
    private DaSjxhDao daSjxhDao;

    @Override
    public List<Integer[]> getDaDealInfo(String start, String end, List<String> dates) {
        List<String> list = daSjxhDao.getDaDealInfo(start, end);
        List<Integer[]> result = new ArrayList<>();
        Integer[] in = new Integer[dates.size()];
        if (list.size() > 0) {
            Object[] str = new String[list.size()];
            str = list.toArray();
            System.out.println("length==" + str.length);
            for (int i = 0; i < dates.size(); i++) {
                for (Object s : str) {
                    if (s.toString().substring(0, 10).equals(dates.get(i))) {
                        in[i] = 1;
                        break;
                    } else {
                        in[i] = 0;
                    }
                }
            }
            result.add(in);
        } else {
            for (int i = 0; i < dates.size(); i++) {
                in[i] = 0;
            }
            result.add(in);
        }
        return result;
    }
}
